News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.contact.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 11
0.94 %0.94%
0.94% 2 / 213
 
Contact
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 11
0.47 %0.47%
0.47% 1 / 212
 public function Contact($userID, $contactID = 0)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 10
 public function getContactData()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 17
 public function deleteContact()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 15
 public function addContact()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 20
 public function updateContact()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 13
 public function getFreeContactOptions()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 40
 public function initNewContact()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 public function getContact()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 25
 public function checkNewContact()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 37
 public function checkContact()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 23
 public function setStyleData()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5


       1                 : <?php                                                                                                                                                               
       2                 : /*--------------------------------------------------------------------------+                                                                                       
       3                 : This file is part of eStudy.                                                                                                                                        
       4                 : user/classes/class.contact.inc.php                                                                                                                                  
       5                 : - Modulgruppe:  Benutzerverwaltung                                                                                                                                  
       6                 : - Beschreibung: Die Klasse "Contact"                                                                                                                                
       7                 : - Version:      0.1, 29/06/04                                                                                                                                       
       8                 : - Autor(en):    Mirko Pitz <mirko.pitz@mni.fh-giessen.de>                                                                                                           
       9                 : +---------------------------------------------------------------------------+                                                                                       
      10                 : This program is free software; you can redistribute it and/or                                                                                                       
      11                 : modify it under the terms of the GNU General Public License                                                                                                         
      12                 : as published by the Free Software Foundation; either version 2                                                                                                      
      13                 : of the License, or any later version.                                                                                                                               
      14                 : +---------------------------------------------------------------------------+                                                                                       
      15                 : This program is distributed in the hope that it will be useful,                                                                                                     
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                      
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                       
      18                 : GNU General Public License for more details.                                                                                                                        
      19                 : You should have received a copy of the GNU General Public License                                                                                                   
      20                 : along with this program; if not, write to the Free Software                                                                                                         
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                         
      22                 : +--------------------------------------------------------------------------*/                                                                                       
      23                 : /**                                                                                                                                                                 
      24                 :  * In dieser Datei wird die Klasse "Contact" implementiert.                                                                                                         
      25                 :  * @package eStudy.User                                                                                                                                             
      26                 :  * @author Mirko Pitz <mirko.pitz@mni.fh-giessen.de>                                                                                                                
      27                 :  * @version  0.1, 29/06/04                                                                                                                                          
      28                 :  */                                                                                                                                                                 
      29                 : /**zum Ausführen der E-Mail-Validierung*/                                                                                                                          
      30               1 : require_once ("class.email.inc.php");                                                                                                                               
      31                 : /**                                                                                                                                                                 
      32                 :  * BESCHREIBUNG                                                                                                                                                     
      33                 :  * @package eStudy.User                                                                                                                                             
      34                 :  * @author Mirko Pitz <mirko.pitz@mni.fh-giessen.de>                                                                                                                
      35                 :  * @version 0.1, 29/06/04                                                                                                                                           
      36                 :  */                                                                                                                                                                 
      37               1 : class Contact {                                                                                                                                                     
      38                 :     /**                                                                                                                                                             
      39                 :      * aktueller Benutzer                                                                                                                                           
      40                 :      *                                                                                                                                                              
      41                 :      * @access public                                                                                                                                               
      42                 :      * @var    integer                                                                                                                                              
      43                 :      */                                                                                                                                                             
      44                 :     var $userID;                                                                                                                                                    
      45                 :     /**                                                                                                                                                             
      46                 :      * aktuelle Kontakt-ID                                                                                                                                          
      47                 :      *                                                                                                                                                              
      48                 :      * @access public                                                                                                                                               
      49                 :      * @var    integer                                                                                                                                              
      50                 :      */                                                                                                                                                             
      51                 :     var $contactID;                                                                                                                                                 
      52                 :     /**                                                                                                                                                             
      53                 :      * Alle Kontakte eines Benutzers                                                                                                                                
      54                 :      *                                                                                                                                                              
      55                 :      * @access public                                                                                                                                               
      56                 :      * @var    array                                                                                                                                                
      57                 :      */                                                                                                                                                             
      58                 :     var $contactData;                                                                                                                                               
      59                 :     /**                                                                                                                                                             
      60                 :      * zunächst leerer Datensatz für neue Adresse                                                                                                                 
      61                 :      *                                                                                                                                                              
      62                 :      * @access public                                                                                                                                               
      63                 :      * @var    array                                                                                                                                                
      64                 :      */                                                                                                                                                             
      65                 :     var $newContact;                                                                                                                                                
      66                 :     /**                                                                                                                                                             
      67                 :      * Aktueller Kontakt                                                                                                                                            
      68                 :      *                                                                                                                                                              
      69                 :      * @access public                                                                                                                                               
      70                 :      * @var    array                                                                                                                                                
      71                 :      */                                                                                                                                                             
      72                 :     var $contact;                                                                                                                                                   
      73                 :     /**                                                                                                                                                             
      74                 :      * Skriptname für Formulare                                                                                                                                    
      75                 :      *                                                                                                                                                              
      76                 :      * @access public                                                                                                                                               
      77                 :      * @var    string                                                                                                                                               
      78                 :      */                                                                                                                                                             
      79                 :     var $actionScript;                                                                                                                                              
      80                 :     /**                                                                                                                                                             
      81                 :      * Array mit Daten aus config.ini                                                                                                                               
      82                 :      *                                                                                                                                                              
      83                 :      * @access public                                                                                                                                               
      84                 :      * @var    array                                                                                                                                                
      85                 :      */                                                                                                                                                             
      86                 :     var $configData;                                                                                                                                                
      87                 :     /**                                                                                                                                                             
      88                 :      * Konstruktor mit Initialisierung der wichtigsten Variablen                                                                                                    
      89                 :      *                                                                                                                                                              
      90                 :      * @access public                                                                                                                                               
      91                 :      * @param  integer $userID - ID des Benutzer, der bearbeitet werden soll                                                                                        
      92                 :      * @param  integer $contactID - ID der Adresse, die bearbeitet werden soll                                                                                      
      93                 :      * @return bool                                                                                                                                                 
      94                 :      */                                                                                                                                                             
      95                 :     function Contact($userID, $contactID = 0) {                                                                                                                     
      96               0 :         if (is_numeric($userID)) $this->userID = $userID;                                                                                                           
      97               0 :         if ($this->userID) {                                                                                                                                        
      98               0 :             $this->actionScript = PATH_TO_ROOT.SCRIPT_NAME."?user=".$this->userID;                                                                                  
      99               0 :             $this->setStyleData();                                                                                                                                  
     100               0 :             if (is_numeric($contactID)) $this->contactID = $contactID;                                                                                              
     101               0 :             if ($this->contactID > 0) {                                                                                                                             
     102               0 :                 $this->actionScript = PATH_TO_ROOT.SCRIPT_NAME."?user=".$this->userID."&amp;adr=".$this->contactID;                                                 
     103               0 :             }                                                                                                                                                       
     104               0 :             return true;                                                                                                                                            
     105                 :         } else {                                                                                                                                                    
     106               0 :             return false;                                                                                                                                           
     107                 :         }                                                                                                                                                           
     108                 :     }                                                                                                                                                               
     109                 :     /**                                                                                                                                                             
     110                 :      * Hole alle Kontakt-Daten, für Übersichtstabellen geeignet                                                                                                   
     111                 :      * BESCHREIBUNG                                                                                                                                                 
     112                 :      * @access public                                                                                                                                               
     113                 :      * @return TYP BESCHREIBUNG                                                                                                                                     
     114                 :      */                                                                                                                                                             
     115                 :     function getContactData() {                                                                                                                                     
     116               0 :         global $db, $EZSQL_ERROR;                                                                                                                                   
     117               0 :         $select = "SELECT user_contacts.contactID AS contactID, ";                                                                                                  
     118               0 :         $select.= " user_contacts.contacttypeID AS contacttypeID, ";                                                                                                
     119               0 :         $select.= " user_contacts.value AS value, ";                                                                                                                
     120               0 :         $select.= " user_contacts.showflag AS showflag, ";                                                                                                          
     121               0 :         $select.= " user_contacttypes.name AS name ";                                                                                                               
     122               0 :         $select.= " FROM user_contacts, user_contacttypes ";                                                                                                        
     123               0 :         $select.= " WHERE user_contacts.userID='".$this->userID."' ";                                                                                               
     124               0 :         $select.= " AND user_contacts.contacttypeID = user_contacttypes.contacttypeID ";                                                                            
     125               0 :         $select.= " ORDER BY name";                                                                                                                                 
     126               0 :         $contactData = $db->get_results($select);                                                                                                                   
     127               0 :         if ($contactData) {                                                                                                                                         
     128               0 :             foreach($contactData as $contactDate) {                                                                                                                 
     129               0 :                 $this->contactData[$contactDate->contactID] = $contactDate;                                                                                         
     130               0 :             }                                                                                                                                                       
     131               0 :             return true;                                                                                                                                            
     132                 :         } else {                                                                                                                                                    
     133               0 :             return false;                                                                                                                                           
     134                 :         }                                                                                                                                                           
     135                 :     }                                                                                                                                                               
     136                 :     /**                                                                                                                                                             
     137                 :      * Lösche Adresse.                                                                                                                                             
     138                 :      *                                                                                                                                                              
     139                 :      * Nachdem geprüft wurde, ob das Löschen erlaubt ist, wird die aktuelle Adresse                                                                               
     140                 :      * aus der Datenbank gelöscht.                                                                                                                                 
     141                 :      * @access public                                                                                                                                               
     142                 :      * @return void                                                                                                                                                 
     143                 :      *                                                                                                                                                              
     144                 :      */                                                                                                                                                             
     145                 :     function deleteContact() {                                                                                                                                      
     146               0 :         global $db, $EZSQL_ERROR;                                                                                                                                   
     147                 :         //Admins dürfen alle Kontakte löschen, alle anderen dürfen nur ihre eigenen löschen                                                                     
     148               0 :         if (!($_SESSION['usergroup'] == 1 || $_SESSION['userid'] == $this->userID)) {                                                                               
     149               0 :             return "Sie haben nicht das Recht, fremde Daten zu löschen!";                                                                                          
     150                 :         }                                                                                                                                                           
     151               0 :         $errorCount = count($EZSQL_ERROR);                                                                                                                          
     152               0 :         $db->query("DELETE FROM user_contacts                                                                                                                       
     153               0 :                     WHERE contactID = '".$this->contactID."'                                                                                                        
     154               0 :                     AND userID ='".$this->userID."'                                                                                                                 
     155               0 :                     LIMIT 1");                                                                                                                                      
     156               0 :         if (count($EZSQL_ERROR) > $errorCount) {                                                                                                                    
     157               0 :             return "Fataler Fehler beim L&ouml;schen der Adressdaten aufgetreten!";                                                                                 
     158                 :         }                                                                                                                                                           
     159               0 :         if ($db->rows_affected == 0) {                                                                                                                              
     160               0 :             return "Ung&uuml;ltige User-ID";                                                                                                                        
     161               0 :         } elseif ($db->rows_affected > 1) {                                                                                                                         
     162               0 :             return $db->rows_affected."Fataler Fehler beim L&ouml;schen der Adressdaten aufgetreten!";                                                              
     163                 :         } else {                                                                                                                                                    
     164               0 :             return true;                                                                                                                                            
     165                 :         }                                                                                                                                                           
     166                 :     }                                                                                                                                                               
     167                 :     /**                                                                                                                                                             
     168                 :      * Füge neue Adresse in Datenbank ein.                                                                                                                         
     169                 :      *                                                                                                                                                              
     170                 :      * Nachdem die Adresse geprüft wurde, wird das Insert durchgeführt.                                                                                           
     171                 :      * @access public                                                                                                                                               
     172                 :      * @return void                                                                                                                                                 
     173                 :      *                                                                                                                                                              
     174                 :      */                                                                                                                                                             
     175                 :     function addContact() {                                                                                                                                         
     176               0 :         global $db, $EZSQL_ERROR;                                                                                                                                   
     177               0 :         if (is_numeric($this->contactID)) {                                                                                                                         
     178                 :             //Daten prüfen                                                                                                                                         
     179               0 :             $validation = $this->checkNewContact();                                                                                                                 
     180               0 :             if ($validation !== true) return $validation;                                                                                                           
     181                 :             //Daten einfügen                                                                                                                                       
     182               0 :             $insertContact = "INSERT INTO user_contacts ";                                                                                                          
     183               0 :             $insertContact.= "(contactID, userID, contacttypeID, value, ";                                                                                          
     184               0 :             $insertContact.= " showflag) ";                                                                                                                         
     185               0 :             $insertContact.= "VALUES (".$this->newContact['contactID'].", ";                                                                                        
     186               0 :             $insertContact.= $this->newContact['userID'].", ";                                                                                                      
     187               0 :             $insertContact.= $this->newContact['contacttypeID'].", ";                                                                                               
     188               0 :             $insertContact.= "'".Data::toMysql(trim($this->newContact['value'])) ."', ";                                                                            
     189               0 :             $insertContact.= $this->newContact['showFlag'].") ";                                                                                                    
     190                 :             //Ergebnis des Insert-SQLs ist die neue Contact-ID                                                                                                      
     191               0 :             $errorCount = count($EZSQL_ERROR);                                                                                                                      
     192               0 :             $db->query($insertContact);                                                                                                                             
     193               0 :             $this->contactID = $db->insert_id;                                                                                                                      
     194               0 :             if (count($EZSQL_ERROR) > $errorCount) {                                                                                                                
     195               0 :                 return "Fataler Fehler beim Speichern der Kontaktdaten aufgetreten!";                                                                               
     196                 :             }                                                                                                                                                       
     197               0 :         } else {                                                                                                                                                    
     198               0 :             return false;                                                                                                                                           
     199                 :         }                                                                                                                                                           
     200               0 :         return true;                                                                                                                                                
     201                 :     }                                                                                                                                                               
     202                 :     /**                                                                                                                                                             
     203                 :      *                                                                                                                                                              
     204                 :      * @access public                                                                                                                                               
     205                 :      * @return void                                                                                                                                                 
     206                 :      *                                                                                                                                                              
     207                 :      */                                                                                                                                                             
     208                 :     function updateContact() {                                                                                                                                      
     209               0 :         global $db, $EZSQL_ERROR;                                                                                                                                   
     210               0 :         $validation = $this->checkContact();                                                                                                                        
     211               0 :         if ($validation !== true) return $validation;                                                                                                               
     212               0 :         $update = "UPDATE user_contacts SET ";                                                                                                                      
     213               0 :         $update.= " value='".Data::toMysql(trim($this->contact['value'])) ."', ";                                                                                   
     214               0 :         $update.= " showflag=".$this->contact['showFlag']." ";                                                                                                      
     215               0 :         $update.= " WHERE userID=".$this->userID;                                                                                                                   
     216               0 :         $update.= " AND contactID=".$this->contactID." LIMIT 1";                                                                                                    
     217               0 :         $errorCount = count($EZSQL_ERROR);                                                                                                                          
     218               0 :         $db->query($update);                                                                                                                                        
     219               0 :         if (count($EZSQL_ERROR) > $errorCount) {                                                                                                                    
     220               0 :             return "Fataler Fehler beim Speichern der Kontakt-Daten aufgetreten!";                                                                                  
     221                 :         }                                                                                                                                                           
     222               0 :         return true;                                                                                                                                                
     223                 :     }                                                                                                                                                               
     224                 :     /**                                                                                                                                                             
     225                 :      *                                                                                                                                                              
     226                 :      * @access public                                                                                                                                               
     227                 :      * @return void                                                                                                                                                 
     228                 :      *                                                                                                                                                              
     229                 :      */                                                                                                                                                             
     230                 :     function getFreeContactOptions() {                                                                                                                              
     231               0 :         global $db, $EZSQL_ERROR;                                                                                                                                   
     232               0 :         $notInList = "";                                                                                                                                            
     233               0 :         $i = 1;                                                                                                                                                     
     234               0 :         $select = "SELECT DISTINCT user_contacts.contacttypeID AS contacttypeID ";                                                                                  
     235               0 :         $select.= "FROM user_contacts ";                                                                                                                            
     236               0 :         $select.= "WHERE user_contacts.userID='".$this->userID."'";                                                                                                 
     237               0 :         $usedContactTypes = $db->get_results($select);                                                                                                              
     238               0 :         if ($usedContactTypes) {                                                                                                                                    
     239               0 :             foreach($usedContactTypes AS $usedContactType) {                                                                                                        
     240               0 :                 if ($i == 1) {                                                                                                                                      
     241               0 :                     $notInList = $usedContactType->contacttypeID;                                                                                                   
     242               0 :                 } else {                                                                                                                                            
     243               0 :                     $notInList.= ",".$usedContactType->contacttypeID;                                                                                               
     244                 :                 }                                                                                                                                                   
     245               0 :                 $i+= 1;                                                                                                                                             
     246               0 :             }                                                                                                                                                       
     247               0 :         }                                                                                                                                                           
     248               0 :         if ($notInList != "") {                                                                                                                                     
     249               0 :             $select = "SELECT user_contacttypes.contacttypeID AS contacttypeID, ";                                                                                  
     250               0 :             $select.= " user_contacttypes.name AS name ";                                                                                                           
     251               0 :             $select.= " FROM user_contacttypes ";                                                                                                                   
     252               0 :             $select.= " WHERE user_contacttypes.contacttypeID NOT IN (".$notInList.")";                                                                             
     253               0 :             $select.= " ORDER BY contacttypeID";                                                                                                                    
     254               0 :             $openContactTypes = $db->get_results($select);                                                                                                          
     255               0 :         } else {                                                                                                                                                    
     256               0 :             $select = "SELECT user_contacttypes.contacttypeID AS contacttypeID, ";                                                                                  
     257               0 :             $select.= " user_contacttypes.name AS name ";                                                                                                           
     258               0 :             $select.= " FROM user_contacttypes ";                                                                                                                   
     259               0 :             $select.= " ORDER BY contacttypeID";                                                                                                                    
     260               0 :             $openContactTypes = $db->get_results($select);                                                                                                          
     261                 :         }                                                                                                                                                           
     262               0 :         $freeContactOptions = array(0 => 'Bitte w&auml;hlen');                                                                                                      
     263               0 :         $i = 0;                                                                                                                                                     
     264               0 :         if ($openContactTypes) {                                                                                                                                    
     265               0 :             foreach($openContactTypes AS $openContactType) {                                                                                                        
     266               0 :                 $freeContactOptions[$openContactType->contacttypeID] = $openContactType->name;                                                                      
     267               0 :                 if ($i < $openContactType->contacttypeID) {                                                                                                         
     268               0 :                     $i = $openContactType->contacttypeID;                                                                                                           
     269               0 :                 }                                                                                                                                                   
     270               0 :             }                                                                                                                                                       
     271               0 :         }                                                                                                                                                           
     272               0 :         return $freeContactOptions;                                                                                                                                 
     273                 :     }                                                                                                                                                               
     274                 :     /**                                                                                                                                                             
     275                 :      * Initialisiere das newContact-Array                                                                                                                           
     276                 :      *                                                                                                                                                              
     277                 :      * @access public                                                                                                                                               
     278                 :      * @return void                                                                                                                                                 
     279                 :      *                                                                                                                                                              
     280                 :      */                                                                                                                                                             
     281                 :     function initNewContact() {                                                                                                                                     
     282               0 :         $this->newContact['contactID'] = 0;                                                                                                                         
     283               0 :         $this->newContact['contacttypeID'] = 0;                                                                                                                     
     284               0 :         $this->newContact['value'] = "NULL";                                                                                                                        
     285               0 :         $this->newContact['showFlag'] = 1;                                                                                                                          
     286               0 :         $this->newContact['userID'] = $this->userID;                                                                                                                
     287               0 :     }                                                                                                                                                               
     288                 :     /**                                                                                                                                                             
     289                 :      *                                                                                                                                                              
     290                 :      * @access public                                                                                                                                               
     291                 :      * @return void                                                                                                                                                 
     292                 :      *                                                                                                                                                              
     293                 :      */                                                                                                                                                             
     294                 :     function getContact() {                                                                                                                                         
     295               0 :         global $db, $EZSQL_ERROR;                                                                                                                                   
     296               0 :         $select = "SELECT user_contacts.contactID AS contactID, ";                                                                                                  
     297               0 :         $select.= "       user_contacts.contacttypeID AS contacttypeID, ";                                                                                          
     298               0 :         $select.= "       user_contacts.value AS value, ";                                                                                                          
     299               0 :         $select.= "       user_contacts.showflag AS showflag, ";                                                                                                    
     300               0 :         $select.= "       user_contacttypes.allowedchars AS allowedchars, ";                                                                                        
     301               0 :         $select.= "       user_contacttypes.type AS type, ";                                                                                                        
     302               0 :         $select.= "       user_contacttypes.name AS name ";                                                                                                         
     303               0 :         $select.= " FROM user_contacts, user_contacttypes ";                                                                                                        
     304               0 :         $select.= " WHERE user_contacts.userID='".$this->userID."' ";                                                                                               
     305               0 :         $select.= " AND user_contacts.contactID='".$this->contactID."' ";                                                                                           
     306               0 :         $select.= " AND user_contacts.contacttypeID = user_contacttypes.contacttypeID ";                                                                            
     307               0 :         $select.= " LIMIT 1";                                                                                                                                       
     308               0 :         $contactData = $db->get_row($select);                                                                                                                       
     309               0 :         if ($contactData) {                                                                                                                                         
     310               0 :             $this->contact['userID'] = $this->userID;                                                                                                               
     311               0 :             $this->contact['contactID'] = $contactData->contactID;                                                                                                  
     312               0 :             $this->contact['contacttypeID'] = $contactData->contacttypeID;                                                                                          
     313               0 :             $this->contact['value'] = $contactData->value;                                                                                                          
     314               0 :             $this->contact['showFlag'] = $contactData->showflag;                                                                                                    
     315               0 :             $this->contact['name'] = $contactData->name;                                                                                                            
     316               0 :             $this->contact['type'] = $contactData->type;                                                                                                            
     317               0 :             $this->contact['allowedchars'] = $contactData->allowedchars;                                                                                            
     318               0 :             return true;                                                                                                                                            
     319                 :         } else {                                                                                                                                                    
     320               0 :             return false;                                                                                                                                           
     321                 :         }                                                                                                                                                           
     322                 :     }                                                                                                                                                               
     323                 :     /**                                                                                                                                                             
     324                 :      * Prüfe neue Adressdaten                                                                                                                                      
     325                 :      *                                                                                                                                                              
     326                 :      * @access public                                                                                                                                               
     327                 :      * @return void                                                                                                                                                 
     328                 :      *                                                                                                                                                              
     329                 :      */                                                                                                                                                             
     330                 :     function checkNewContact() {                                                                                                                                    
     331               0 :         global $db, $EZSQL_ERROR;                                                                                                                                   
     332               0 :         if ($this->newContact['contacttypeID'] == 0) {                                                                                                              
     333               0 :             $errors[] = "- Bitte w&auml;hlen Sie einen <strong>Adresstyp</strong> aus!";                                                                            
     334               0 :             $this->styles['contacttypeID'] = $this->styles['errorRow'];                                                                                             
     335               0 :         } else {                                                                                                                                                    
     336               0 :             if ($db->get_var("SELECT contactID FROM user_contacts WHERE contacttypeID = '".$this->newContact['contacttypeID']."' AND userID='".$this->userID."'")) {
     337               0 :                 $errors[] = "- Adresse existiert bereits!";                                                                                                         
     338               0 :                 $this->styles['contacttypeID'] = $this->styles['errorRow'];                                                                                         
     339               0 :             }                                                                                                                                                       
     340               0 :             $contactType = $db->get_var("SELECT type FROM user_contacttypes WHERE contacttypeID = '".$this->newContact['contacttypeID']."'");                       
     341                 :         }                                                                                                                                                           
     342               0 :         if (trim($this->newContact['value']) == "") {                                                                                                               
     343               0 :             $errors[] = "- Bitte geben Sie eine passende <strong>Adresse</strong> ein!";                                                                            
     344               0 :             $this->styles['value'] = $this->styles['errorRow'];                                                                                                     
     345               0 :         } elseif (isset($contactType)) {                                                                                                                            
     346               0 :             if ($contactType == 1) {                                                                                                                                
     347               0 :                 if (!Email::validate($this->newContact['value'])) {                                                                                                 
     348               0 :                     $errors[] = "- Diese <strong>Adresse</strong> ist ung&uuml;ltig!";                                                                              
     349               0 :                     $this->styles['value'] = $this->styles['errorRow'];                                                                                             
     350               0 :                 }                                                                                                                                                   
     351               0 :             } elseif ($contactType == 2) {                                                                                                                          
     352               0 :                 if (!(Utilities::validateURL($this->newContact['value']))) {                                                                                        
     353               0 :                     $errors[] = "- Diese <strong>URL</strong> ist ung&uuml;ltig!";                                                                                  
     354               0 :                     $this->styles['value'] = $this->styles['errorRow'];                                                                                             
     355               0 :                 }                                                                                                                                                   
     356               0 :             }                                                                                                                                                       
     357               0 :         } else {                                                                                                                                                    
     358               0 :             $allowedChars = $db->get_var("SELECT allowedchars FROM user_contacttypes WHERE contacttypeID=".$this->newContact['contacttypeID']);                     
     359               0 :             if (trim($allowedChars)) {                                                                                                                              
     360               0 :                 if (!ereg("^[".$allowedChars."]*$", trim($this->newContact['value']))) {                                                                            
     361               0 :                     $errors[] = "- Die <strong>Adresse</strong> enth&auml;lt ung&uuml;ltige Zeichen!";                                                              
     362               0 :                     $errors[] = "- gültige Zeichen sind : $allowedChars";                                                                                          
     363               0 :                     $this->styles['value'] = $this->styles['errorRow'];                                                                                             
     364               0 :                 }                                                                                                                                                   
     365               0 :             }                                                                                                                                                       
     366                 :         }                                                                                                                                                           
     367                 :         //Wenn Fehler vorliegen, werden sie zur&uuml;ckgegeben                                                                                                      
     368               0 :         if (isset($errors)) {                                                                                                                                       
     369               0 :             return implode($errors, "<br />\n");                                                                                                                    
     370                 :         } else {                                                                                                                                                    
     371               0 :             return true;                                                                                                                                            
     372                 :         }                                                                                                                                                           
     373                 :     }                                                                                                                                                               
     374                 :     /**                                                                                                                                                             
     375                 :      * Prüfe bearbeitete Adressdaten                                                                                                                               
     376                 :      *                                                                                                                                                              
     377                 :      * @access public                                                                                                                                               
     378                 :      * @return mixed bool TRUE Daten in Ordnung                                                                                                                     
     379                 :      *                  string Fehlermeldung                                                                                                                        
     380                 :      *                                                                                                                                                              
     381                 :      */                                                                                                                                                             
     382                 :     function checkContact() {                                                                                                                                       
     383               0 :         if (trim($this->contact['value']) == "") {                                                                                                                  
     384               0 :             $errors[] = "- Bitte geben Sie eine passende Adresse ein!";                                                                                             
     385               0 :         } elseif ($this->contact['type']) {                                                                                                                         
     386               0 :             if ($this->contact['type'] == 1) {                                                                                                                      
     387               0 :                 if (!Email::validate($this->contact['value'])) {                                                                                                    
     388               0 :                     $errors[] = "- Diese <strong>E-Mail-Adresse</strong> ist ung&uuml;ltig!";                                                                       
     389               0 :                 }                                                                                                                                                   
     390               0 :             } elseif ($this->contact['type'] == 2) {                                                                                                                
     391               0 :                 if (!(Utilities::validateURL($this->contact['value']))) {                                                                                           
     392               0 :                     $errors[] = "- Diese <strong>URL</strong> ist ung&uuml;ltig!";                                                                                  
     393               0 :                 }                                                                                                                                                   
     394               0 :             }                                                                                                                                                       
     395               0 :         } else {                                                                                                                                                    
     396               0 :             if (trim($this->contact['allowedchars'])) {                                                                                                             
     397               0 :                 if (!ereg("^[".$this->contact['allowedchars']."]*$", trim($this->contact['value']))) {                                                              
     398               0 :                     $errors[] = "- Die <strong>Adresse</strong> enth&auml;lt ung&uuml;ltige Zeichen!";                                                              
     399               0 :                     $errors[] = "- gültige Zeichen sind : ".$this->contact['allowedchars'];                                                                        
     400               0 :                 }                                                                                                                                                   
     401               0 :             }                                                                                                                                                       
     402                 :         }                                                                                                                                                           
     403                 :         //Wenn Fehler vorliegen, werden sie zur&uuml;ckgegeben                                                                                                      
     404               0 :         if (isset($errors)) {                                                                                                                                       
     405               0 :             $this->styles['value'] = $this->styles['errorRow'];                                                                                                     
     406               0 :             return implode($errors, "<br />\n");                                                                                                                    
     407                 :         } else {                                                                                                                                                    
     408               0 :             return true;                                                                                                                                            
     409                 :         }                                                                                                                                                           
     410                 :     }                                                                                                                                                               
     411                 :     /**                                                                                                                                                             
     412                 :      * Legt zentrale CSS-Style-Informationen in einem Array ab.                                                                                                     
     413                 :      *                                                                                                                                                              
     414                 :      * Diese Styles werden in den Formularen verwendet.                                                                                                             
     415                 :      * @access public                                                                                                                                               
     416                 :      * @return void                                                                                                                                                 
     417                 :      *                                                                                                                                                              
     418                 :      */                                                                                                                                                             
     419                 :     function setStyleData() {                                                                                                                                       
     420               0 :         $this->styles['tableHead'] = "tableSubHeaderDark";                                                                                                          
     421               0 :         $this->styles['tableRow'] = "tableCell";                                                                                                                    
     422               0 :         $this->styles['errorRow'] = "tableCellError";                                                                                                               
     423               0 :         $this->styles['infoText'] = "tableCellSmall";                                                                                                               
     424               0 :     }                                                                                                                                                               
     425                 : }                                                                                                                                                                   

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.